package cn.iocoder.yudao.module.member.dal.mysql.images;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.images.vo.ImagesExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.images.vo.ImagesPageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.images.ImagesDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 用户图片 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ImagesMapper extends BaseMapperX<ImagesDO> {

    default PageResult<ImagesDO> selectPage(ImagesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ImagesDO>()
                .eqIfPresent(ImagesDO::getThirdId, reqVO.getUserId())
                .eqIfPresent(ImagesDO::getType, reqVO.getType())
                .eqIfPresent(ImagesDO::getImageLink, reqVO.getImageLink())
                .eqIfPresent(ImagesDO::getStatus, 0)
                .betweenIfPresent(ImagesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ImagesDO::getId));
    }

    default List<ImagesDO> selectList(ImagesExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ImagesDO>()
                .eqIfPresent(ImagesDO::getThirdId, reqVO.getThirdId())
                .eqIfPresent(ImagesDO::getType, reqVO.getType())
                .eqIfPresent(ImagesDO::getImageLink, reqVO.getImageLink())
                .eqIfPresent(ImagesDO::getStatus, 0)
                .betweenIfPresent(ImagesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ImagesDO::getId));
    }

}
